if (typeof xcsoft == "undefined") var xcsoft = new function() {};

xcsoft.countdown2 = function(a, b, c) {//a服务器上现在的时间，b倒计时分钟数，c显示函数
    var d = new Object();
    var e = Date.parse(a)/ 1000;
	b*=60;
	d.decimal = 0;
    d.time = e+b;//终止时间
    d.finish = false;
    d.day = 0;
    d.hour = 0;
    d.minute = 0;
    d.second = 0;
	d.l=b;
    d.t = setInterval(function() {
        e++;
        d.l = d.time - e;//剩余秒数
        if (d.l < 0) {
            e = 0; d.l = 0;
			clearInterval(d.t);
            d.finish = true;
        }else if (d.l >= 0){
			d = xcsoft._1(d, l);//统一换算
			if(d.l==300)$.modal.alertWarning("考试还剩余5分钟<br /><span style='color:red'>请在考试结束前交卷！</span>");
			else if(d.l==30)$.modal.alertWarning("考试只剩余30秒钟，请交卷！");
		} 
		if (c)c(d);//显示
    }, 1000)
};
xcsoft.countdown = function(a, b, c) {
    var d = new Object();
    var e = 0;
    if (typeof a == "object") {
        var f = parseInt(new Date().getTime() / 1000);
        var g = a.startTime ? parseInt(a.startTime) : 0;
        g = g == 0 ? f : g;
        var h = a.endTime;
        var x = g - f;
        d.decimal = parseInt(a.msec ? a.msec : 0)
    } else {
        var f = 0;
        var x = 0;
        d.decimal = 0;
        var h = a;
        var i = h.toString();
        if (i.indexOf('.') > 0) {
            d.decimal = i.split('.')[1];
            if (d.decimal > 3) {
                d.decimal = 3
            }
        }
    }
    d.time = h;
    d.finish = false;
    if (isNaN(h)) {
        var j = h.substring(0, 19);
        j = j.replace(/-/g, '/');
        d.time = new Date(j).getTime() / 1000
    }
    var k = d.decimal == 0 ? 100 : 100;
    d.day = 0;
    d.hour = 0;
    d.minute = 0;
    d.second = 0;
    d.t = setInterval(function() {
        e = new Date().getTime();
        f = parseInt(e / 1000 + x);
        var l = d.time - f;
        if (l <= 0) {
            e = 0;
            l = 0
        }
        if (l >= 0) {
            d = xcsoft._1(d, l)
        }
        if (d.decimal == 1) {
            d.msecZero = d.msec = parseInt(10 - e % 1000 / 100);
            if (d.msec == 10 || l == 0) {
                d.msecZero = d.msec = 0
            }
        } else if (d.decimal == 2) {
            d.msecZero = d.msec = parseInt(100 - e % 1000 / 10);
            if (d.msec < 10) {
                d.msecZero = '0' + d.msec
            } else if (d.msec == 100 || l == 0) {
                d.msec = 0;
                d.msecZero = '0' + d.msec
            }
        } else {
            d.msecZero = d.msec = parseInt(1000 - e % 1000);
            if (d.msec < 10) {
                d.msecZero = '00' + d.msec
            } else if (d.msec < 100) {
                d.msecZero = '0' + d.msec
            } else if (d.msec == 1000 || l == 0) {
                d.msec = 0;
                d.msecZero = '00' + d.msec
            }
        } if (b) {
            b(d)
        }
        if (l <= 0 || d.stop == true) {
            clearInterval(d.t);
            d.finish = true;
            if (c) c(d)
        }
    }, k)
};
xcsoft.countup = function(c, d) {
    if (!c) {
        var e = new Date().getTime();
        c = parseInt(e / 1000)
    } else if (isNaN(c)) {
        c = c.replace(/-/g, '/');
        var e = new Date(c).getTime();
        c = parseInt(e / 1000)
    }
    var f = new Object();
    f.time = c;
    f.t = setInterval(function() {
        var a = new Date().getTime();
        nowtime = parseInt(a / 1000);
        var l = nowtime - c;
        f = xcsoft._1(f, l);
        if (d) var b = d(f);
        if (b === true) {
            clearTimeout(f.t)
        }
    }, 100)
};
xcsoft.now = function(b) {
    var c = {};
    setInterval(function() {
        var a = new Date();
        c.date = a;
        c.year = a.getFullYear();
        c.month = a.getMonth() + 1;
        c.day = c.days = a.getDate();
        c.hour = a.getHours();
        c.minute = a.getMinutes();
        c.second = a.getSeconds();
        if (b) b(xcsoft._0(c))
    }, 100)
};
xcsoft.counter = function(t, b) {
    var c = {};
    var a;
    if (t == null) a = new Date();
    else a = new Date(t);
    setInterval(function() {
        c.date = a;
        c.year = a.getFullYear();
        c.month = a.getMonth() + 1;
        c.day = c.days = a.getDate();
        c.hour = a.getHours();
        c.minute = a.getMinutes();
        c.second = a.getSeconds();
        if (b) b(xcsoft._0(c));
        a = new Date(a.getTime() + 1000)
    }, 1000)
};
xcsoft._1 = function(a, l) {
    var b = 60;
    var c = b * b;
    var d = 24 * c;
    a.days = Math.floor(l / d);
    a.year = Math.floor(a.days / 365);
    a.day = Math.floor(a.days % 365);
    a.hour = Math.floor(l % d / c);
    a.minute = Math.floor((l - (a.days * d + a.hour * c)) / b);
    a.second = Math.floor(l % (b));
    return xcsoft._0(a)
};
xcsoft.countdown3 = function(a,b,c){
	var d = new Object();
	var j = a.substring(0, 19).replace(/-/g, '/');
    var g = new Date(j).getTime() / 1000;//服务器当前时间
    var f = parseInt(new Date().getTime() / 1000);//客户机当前时间s
    var x=g-f;//offset
    d.time=new Date(b.substring(0, 19).replace(/-/g, '/')).getTime() / 1000;//终止时间
    d.finish = false;
    d.t = setInterval(function() {
    	e = new Date().getTime();
        f = parseInt(e / 1000 + x);
        var l = d.time - f;
        if (l <= 0) {
            e = 0;
            l = 0
        }
    	if (l >= 0) {
            d = xcsoft._2(d,l)
        }
    	if (c)  c(d);
    	if (l <= 0 || d.stop == true) {
            clearInterval(d.t);
            d.finish = true;
            //if (c) c(d)
        }
    },1000)
}
xcsoft._2 = function(a,l) {
    var b = 60;
    var c = b * b;
    var d = 24 * c;
    a.days = 0;
    a.year = 0;
    a.day = 0;
    a.hour = Math.floor(l / c);
    a.minute = Math.floor((l - ( a.hour * c)) / b);
    a.second = Math.floor(l % (b));
    return xcsoft._0(a)
};
xcsoft._0 = function(a) {
    a.monthZero = a.month < 10 ? '0' + a.month : a.month;
    a.dayZero = a.day < 10 ? '0' + a.day : a.day;
    a.daysZero = a.days < 10 ? '0' + a.days : a.days;
    a.hourZero = a.hour < 10 ? '0' + a.hour : a.hour;
    a.minuteZero = a.minute < 10 ? '0' + a.minute : a.minute;
    a.secondZero = a.second < 10 ? '0' + a.second : a.second;
    return a
}